Skip to content

Add rules : prohibited_with, prohibited_with_all, prohibited_without, prohibited_without_all + Modify rules In + NotIn to manage array values #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zephyx
Copy link
Contributor

@zephyx zephyx commented May 25, 2025

In my project I needed some new rules like prohibited_with, prohibited_with_all, prohibited_without, prohibited_without_all
I also needed to validate an array with the In rule, but this one wasn't accepting an array value, I modified it.

I have added translations but only french and english ones are actives, the other ones are commented because I have used a translation tool and I can't be sure they are correct.

… prohibited_without_all

Modify rules In + NotIn to manage array values
Copy link
Member

@dave-redfern dave-redfern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are your thoughts about combining AnyOf and In? I am interested in your feedback.

@@ -44,6 +44,16 @@ public function check(mixed $value): bool
{
$this->assertHasRequiredParameters(['allowed_values']);

if (is_array($value)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is "AnyOf" that allows for validating an array of values are each within an array of allowed values. I am not sure how I feel about combining "In" to do both. I checked Laravels code and see that it does allow this, though "AnyOf" allows a string of delineated values as well.

@@ -45,6 +45,16 @@ public function check(mixed $value): bool
{
$this->assertHasRequiredParameters(['disallowed_values']);

if (is_array($value)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the comments from In, I am not sure about combining this into the NotIn rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants